import redis
import logging

class Config(object):
    """工程配置信息"""
    DEBUG = True
    SECRET_KEY = "kldsiodsnz,mfaoi"

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:gm931227@localhost:3306/inews"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 设置session的配置信息
    SESSION_TYPE = "redis"  # 设置session的存储类型
    SESSION_REDIS = redis.StrictRedis(host="127.0.0.1", port=6379)  # session,redis的保存位置
    SESSION_USE_SIGNER = True  # 签名存储
    # app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(days=2) #两天有效期
    PERMANENT_SESSION_LIFETIME = 66666  # 10秒有效期,单位秒

    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 默认日志等级
    LOG_LEVEL = logging.DEBUG

class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True

class ProductionConfig(Config):
    """生产模式下的配置"""
    LOG_LEVEL = logging.ERROR


# 定义配置字典
config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig
}